# from typing import NamedTuple
# import datetime
#
# class Headers(NamedTuple):
#     method: str
#     accept: str
#     accept_lang: str
#     token: str
#     # date: datetime.date
#     version: str
#
# # print(datetime.datetime.now().strftime())
# # print(datetime.datetime.strptime("2021-04-01 20:31:20.335237", "%Y-%m-%d "))
#
# b = bytearray()
# b.extend(b'{"headers": {"method": 1, "accept": "", "token": "", "date": "2021-04-03/17:24:23 6", "version": ""}, "body": {"account": 320822007, "password": "159180", "number": null, "pic": null, "info": null, "img": null, "msg": null, "name": null}}')
# b.decode()


# def process(i, lst, ok, interval):
#     while True:
#         if i >= len(lst):
#             i -= interval
#         if lst[i] is None:
#             i += 1
#         else:
#             lst[i] = None
#             ok[0] += 1
#             break
#     return i
#
#
# def main():
#     length, interval = list(map(int, input().split()))
#     lst = list(range(length))
#     i = interval
#     ok = [1]
#     while True:
#         i = process(i, lst, ok, interval)
#         lst[i] = None
#         i += interval
#
#         if ok[0] == len(lst) - 1:
#             break
#     for i in lst:
#         if i is not None:
#             print(i)
#             break
#
#
# if __name__ == "__main__":
#     main()


import time


def finduglynum2():
    uglynum = [1]
    n = int(input())

    i = 1
    t2 = m2 = 0
    t3 = m3 = 0
    t5 = m5 = 0
    while i < n:
        for x in range(t2, len(uglynum)):
            m2 = uglynum[x] * 2
            # print("m2:",m2,end=" ")
            if m2 > uglynum[-1]:
                t2 = x
                # print("t2:",t2)
                break
        for x in range(t3, len(uglynum)):
            m3 = uglynum[x] * 3
            # print("m3:",m3,end=" ")
            if m3 > uglynum[-1]:
                t3 = x
                # print("t3:",t3)
                break
        for x in range(t5, len(uglynum)):
            m5 = uglynum[x] * 5
            # print("m5",m5,end=" ")
            if m5 > uglynum[-1]:
                t5 = x
                # print("t5:",t5)
                break
        uglynum.append(min(m2, m3, m5))
        i += 1
    print(uglynum)

finduglynum2()


def ugly(n):
    ugly_num = {2, 3, 5}
    new_ugly = [1, 2, 3]
    for i in range(1, n):
        if i / 2 in ugly_num or i / 3 in ugly_num or i / 5 in ugly_num:
            new_ugly.append(i)
            continue
        # if i % 2 and i % 3 or i % 5:
        #     new_ugly.append(i)
    print(new_ugly)


ugly(13)

"""编程题|15.0分2/2
丑数
时间限制： 3000MS
内存限制： 589824KB
题目描述：
只含有2、3、5因子的数是丑数，求第1500个丑数



输入描述
1

输出描述
输出第1500个丑数的位置


样例输入
3
样例输出
859963392

提示
按顺序保存已知的丑数，下一个是已知丑数中某三个数乘以2，3，5中的最小值。
规则
请尽量在全场考试结束10分钟前调试程序，否则由于密集排队提交，可能查询不到编译结果
点击“调试”亦可保存代码
编程题可以使用本地编译器，此页面不记录跳出次数"""